#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
int search(int* nums, int numsLen, int target) {
    int left = 0, right = numsLen - 1;
    int tmp = 0, mid;
    while (left <= right)
    {
        mid = (left + right) / 2;
        if (nums[mid] == target)
        {
            tmp = 1;
            break;
        }
        else if (nums[mid] < target)
            left = mid + 1;
        else
            right = mid - 1;
    }
    return tmp ? mid : -1;
}
int main()
{
    int arr[10] = { 1,2,3,4,5,6,7,8,9,10 };
    printf("%d", search(arr, 10, 7));
    return 0;
}